package com.xjrsoft.module.customer.erp_model.warehouseManage.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customer.erp_model.warehouseManage.entity.ErpWarehouse;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.module.customer.erp_model.warehouseManage.dto.ErpWarehouseListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.module.customer.erp_model.warehouseManage.mapper.ErpWarehouseMapper;
import com.xjrsoft.module.customer.erp_model.warehouseManage.service.IErpWarehouseService;
import com.xjrsoft.core.mp.base.BaseService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author pp
 * @since 2021-09-23
 */
@Service
@AllArgsConstructor
public class ErpWarehouseServiceImpl extends BaseService<ErpWarehouseMapper, ErpWarehouse> implements IErpWarehouseService {


	@Override
	public IPage<ErpWarehouse> getPageList(ErpWarehouseListDto pageListDto) {
		Wrapper<ErpWarehouse> wrapper = Wrappers.<ErpWarehouse>query().lambda()				.like(!StringUtil.isEmpty(pageListDto.getF_EnCode()), ErpWarehouse::getFEncode, pageListDto.getF_EnCode())
				.like(!StringUtil.isEmpty(pageListDto.getF_FullName()), ErpWarehouse::getFFullname, pageListDto.getF_FullName());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public String addErpWarehouse(ErpWarehouse erpWarehouse) {
		String erpWarehouseId = IdWorker.get32UUID();
		erpWarehouse.setFId(erpWarehouseId);
		boolean isSuccess = this.save(erpWarehouse);
		return isSuccess ? erpWarehouseId : null;
	}

	@Override
	public boolean updateErpWarehouse(String id, ErpWarehouse erpWarehouse) {
		erpWarehouse.setFId(id);
		return this.updateById(erpWarehouse);
	}

}
